package com.tydic.borderer.listener;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import com.tydic.borderer.domain.MutualHelpOrganizationMember;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class MutualHelpOrganizationMemberListener implements ReadListener<MutualHelpOrganizationMember> {

    private List<MutualHelpOrganizationMember> mutualHelpOrganizationMembers;

    public MutualHelpOrganizationMemberListener(List<MutualHelpOrganizationMember> mutualHelpOrganizationMembers) {
        this.mutualHelpOrganizationMembers = mutualHelpOrganizationMembers;
    }

    @Override
    public void invoke(MutualHelpOrganizationMember mutualHelpOrganizationMember, AnalysisContext analysisContext) {
        if (mutualHelpOrganizationMembers == null || StrUtil.isBlank(mutualHelpOrganizationMember.getIdCardNumber())) {
            return;
        }
        mutualHelpOrganizationMembers.add(mutualHelpOrganizationMember);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
